<?php
// $Id$

/**
 * Controller_Admin_System 控制器
 */
class Controller_Admin_finance extends Controller_Abstract
{	
    /**
     * 数据统计
     */
	function actionindex()
	{
	    $this->union_table = finance::meta();
	    $this->lists();
	}

	function actionoutput(){
	    $sql = ($_SESSION['lastsql']);
	    $obj = call_user_func_array(array(finance::meta(),'find'), $sql);
	    $datas = $obj->order('id desc')->getAll();
	 
	    $data = array();
	    foreach ($datas as $k=>$v){
	        $data[$k]['total_sale']  = $v->total_sale;
	        $data[$k]['user_rewardsale']  = $v->user_rewardsale;
	        $data[$k]['user_totalwithdraw']  = $v->user_totalwithdraw;
	        $data[$k]['user_unwithdraw']  = $v->user_unwithdraw;
	        $data[$k]['day']  = $v->day;
	        $data[$k]['lirun']  = $v->total_sale-$v->user_rewardsale;  
	    }
	    
	    $title = array(
	        'A1'=>'日期',
	        'B1'=>'销售额',
	        'C1'=>'分佣出去金额',
	        'D1'=>'已提现金额',
	        'E1'=>'未提现金额',
	        'F1'=>'净利润',
	    );
	
	    $titlekey = 'tongji';
	    $width = 22; $height = 20;
	   
	    Helper_paylogexcel::generateuserslogxls($title,$titlekey,$width,$data,$height);
	}
	

}


